extends Node

var sceneFileDict
signal signalGameStart
signal signalDebugMessage
signal signalPlayerHit
signal signalGameEnd


func _ready():
	sceneFileDict = {
		"Bullet01": preload("res://Scenes/Bullet/Bullet01.tscn"),
		"Bullet02": preload("res://Scenes/Bullet/Bullet02.tscn"),
		"MainGame": preload("res://Scenes/MainGame.tscn"),
		"Funnel": preload("res://Scenes/Characters/Funnel.tscn"),
		"BulletAutoTrace": preload("res://Scenes/Bullet/BulletAutoTrace.tscn")
	}


func changeScrennOrientation2Landscape():
	DisplayServer.screen_set_orientation(DisplayServer.SCREEN_LANDSCAPE)


func changeScrennOrientation2Portrait():
	DisplayServer.screen_set_orientation(DisplayServer.SCREEN_PORTRAIT)


func changeScene(sceneName):
	get_tree().current_scene.queue_free()
	var sceneInstance = sceneFileDict[sceneName].instantiate() 
	get_tree().root.add_child(sceneInstance) 
	get_tree().current_scene = sceneInstance 


func createSceneInst(sceneName):
	return sceneFileDict[sceneName].instantiate() 
	

func getSoundStream(soundName):
	return sceneFileDict[soundName]
	
	
func isOSWindows():
	var osName = OS.get_name()
	return osName == "Windows"
	

func exitGame():
	get_tree().quit()
	
	
func angle2Vector(angDeg):
	var angRad = deg_to_rad(angDeg)
	var result = Vector2(cos(angRad), sin(angRad))
	return result.normalized()
	

func vector2Angle(vec:Vector2):
	var angRad = vec.angle()
	return rad_to_deg(angRad)
	

func angle2Positive(angle):
	var result = angle
	if result < 0:
		result += 360.0
	return result
